//
//  HeaderView.m
//  K8彩票
//
//  Created by zhoubo on 2017/6/7.
//  Copyright © 2017年 zhoubo. All rights reserved.
//

#import "HeaderView.h"

#import "LoopView.h"
#import "TabbarButton.h"
#import "SliderView.h"
#import "LoopModel.h"
#import <BmobSDK/Bmob.h>




@interface HeaderView ()

@property(nonatomic,weak)LoopView* loopView;

@property(nonatomic,weak)UIView* tipsView;

@property(nonatomic,weak)SliderView* sliderView;

@property (nonatomic,strong) NSArray* loopmodels;


@end

@implementation HeaderView


-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder]) {
        
        [self setup];
    }
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self  = [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}


// 自身高度为415
-(void)setup
{
    LoopView* loopView = [[LoopView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*0.62) andCount:5];
    
    [self addSubview:loopView];
    
    self.loopView = loopView;
    

    
    self.sliderView = [[NSBundle mainBundle] loadNibNamed:@"SliderView" owner:nil options:nil].lastObject;
    
    self.sliderView.frame = CGRectMake(0, CGRectGetMaxY(loopView.frame), [UIScreen mainScreen].bounds.size.width, 30);
    [self addSubview:self.sliderView];
    self.sliderView.backgroundColor = [UIColor colorWithRed:121/255.0 green:213/255.0 blue:253/255.0 alpha:1];

    
    [LoopModel loadLoopsWithName:@"LoopNews" success:^(NSArray *arr) {
        self.loopmodels = arr;
        
        
    } faild:^(NSError *err) {
        NSLog(@"error");
    }];
    

}

-(void)setLoopmodels:(NSArray *)loopmodels
{
    _loopmodels = loopmodels;
    self.loopView.models = loopmodels;
}


-(void)setSecondView
{
    CGFloat width = [UIScreen mainScreen].bounds.size.width/4;
    CGFloat height = 100;
    
    UIView* tipsView = [[UIView alloc]initWithFrame:CGRectMake(0, self.loopView.frame.size.height, [UIScreen mainScreen].bounds.size.width, height)];
    
    self.tipsView = tipsView;
    tipsView.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:tipsView];
    
    
    NSArray* imgs = @[@"tab1",@"tab2",@"tab6",@"tab4"];
    NSArray* titles = @[@"充值",@"提现",@"投注记录",@"客服"];
    
    
    
    
    for(int i = 0 ; i<4; i++)
    {
        CGFloat x = width*i ;
        CGFloat y = 5;
        TabbarButton* btn = [TabbarButton buttonWithFontsize:15 andTextColor:[UIColor blackColor]];
        
        btn.frame = CGRectMake(x, y,width, height);
        
        
        [btn setImage:[UIImage imageNamed:imgs[i]] forState:UIControlStateNormal];
        
        [btn setTitle:titles[i] forState:UIControlStateNormal];
        
        [tipsView addSubview:btn];
    }
    
}


-(void)setModel:(IssueModel *)model
{
    _model = model;
}




@end
